---
title: Forced Layout
description: Strict document structure.
---

<ComponentPreview name="playground-demo" id="forcedlayout" />

<PackageInfo>

## Features

- Automatically ensures the use of specified elements as required to maintain document structure (e.g., first block should be an H1 element).

</PackageInfo>

## Installation

```bash
npm install @udecode/plate-normalizers @udecode/plate-trailing-block
```

## Usage

```tsx
import { NormalizersPlugin } from '@udecode/plate-normalizers/react';
import { TrailingBlockPlugin } from '@udecode/plate-trailing-block/react';
import { ParagraphPlugin } from '@udecode/plate-common/react';
import { HEADING_KEYS } from '@udecode/plate-heading/react';

const plugins = [
  // ...otherPlugins
  TrailingBlockPlugin.configure({ options: { type: ParagraphPlugin.key } }),
  NormalizersPlugin.configure({
    options: {
      rules: [{ path: [0], strictType: 'h1' }],
    },
  }),
];
```

## Plugins

### TrailingBlockPlugin

<APIOptions>
<APIItem name="level" type="number" optional>
Level where the trailing node should be, the first level being 0.

- **Default:** `0`
</APIItem>

<APIItem name="type" type="string" optional>
Type of the trailing block.

- **Default:** `editor.getType(ParagraphPlugin)`
</APIItem>
</APIOptions>

The `TrailingBlockPlugin` also extends `QueryNodeOptions`, which includes additional options for querying nodes.

### NormalizeTypesPlugin

<APIOptions>
<APIItem name="rules" type="Rule[]" optional>
An array of rule objects for normalizing types.

- **Default:** `[]`
</APIItem>
</APIOptions>

#### Rule

<APIAttributes>
<APIItem name="path" type="Path">
Path where the rule applies.
</APIItem>

<APIItem name="strictType" type="string" optional>
Force the type of the node at the given path.
</APIItem>

<APIItem name="type" type="string" optional>
Type of the inserted node at the given path if `strictType` is not provided.
</APIItem>
</APIAttributes>
